package com.example.java_chatroom_redis_rabbitmq.mapper;

import com.example.java_chatroom_redis_rabbitmq.model.Message;
import com.example.java_chatroom_redis_rabbitmq.model.NewFriend;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface NewFriendMapper {
    @Insert("insert into new_friend values(null,#{fromId},#{fromName},#{fromImage},#{postTime},#{toId})")
    Integer addNewFriend(Message message);

    @Delete("delete from new_friend where fromId=#{fromId} and toId=#{toId}")
    Integer deleteNewFriend(@Param("fromId") Integer fromId,@Param("toId") Integer toId);

    @Select("select fromId,fromName,fromImage,postTime from new_friend where toId=#{toId} order by postTime asc")
    List<NewFriend> getNewFriendList(@Param("toId") Integer toId);
}
